package Operations;


public class StringGenerator {


  public String newString(float nullProb) {
    int n = ValuesGenerator.getRandomInt(100);
    if (ValuesGenerator.getBoleean(nullProb)) 
    	return null;
    return newString();
  }

  public String newString() {
    int n = ('z' - 'a') + 1 + ('Z' - 'A') + 1 + ('9' - '0') + 1;
    char chars[] = new char[n];
    int i = 0;
    for (char c = 'a' ; c <= 'z' ; c++) 
      chars[i++] = c;
    for (char c = 'A' ; c <= 'Z' ; c++) 
      chars[i++] = c;
    for (char c = '0' ; c <= '9' ; c++) 
      chars[i++] = c;
    String s = "";
    int addMoreChars = ValuesGenerator.getRandomInt(100);
    while (addMoreChars < 50) {
      n = ValuesGenerator.getRandomInt(chars.length);
      s += chars[n];
      addMoreChars = ValuesGenerator.getRandomInt(100);;
    }
    return s;
  }


  public static void main(String args[]) {
    StringGenerator gen = new StringGenerator();
    while(true)
      System.out.println(gen.newString(0.05f));
    
  }
}


